use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct Struct yata::indicators::DonchianChannel Donchian Channel
///
///  参见[DCC](https://en.wikipedia.org/wiki/Donchian_channel)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct DCC {
    ///1 signal
    /// When high value hits upper bound, returns full buy signal.
    /// When low value hits lower bound, returns full sell signal.
    /// Otherwise returns no signal. If both values hit both bounds, returns no signal.
    pub signal0: Option<IndicatorActionWrap>,
    /// 3 values
    /// Lower bound
    /// Range is the same as high values.
    pub lower: ValueType,

    ///Middle value
    ///It is always middle value between upper bound and lower bound
    ///
    ///Range is the same as high and low values.
    pub middle: ValueType,
    ///
    ///Upper bound
    ///Range is the same as low values.
    pub upper: ValueType,
}

/// Configuration Donchian Channel
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct DCCConfig {
    /// period: PeriodType
    /// Main period. Default is 20.
    ///
    /// Range in [2; PeriodType::MAX)
    pub period: PeriodType,
}

impl Default for DCCConfig {
    fn default() -> Self {
        Self { period: 20 }
    }
}
